#include "MainWindow.h"
#include "DisplayController.h"
#include <QtGui>

MainWindow::MainWindow(DisplayController* pController)
{
	_pController = pController;
	_pLeftColumn = new DisplayWidget(pController, this);
	_pRightColumn = new DisplayWidget(pController, this);

	_pScaleX = new QSpinBox(this);
	
	QVBoxLayout *rowLayout = new QVBoxLayout;
	rowLayout->addWidget(_pLeftColumn);
	rowLayout->addWidget(_pScaleX);
	
	QHBoxLayout* columnLayout = new QHBoxLayout;
	columnLayout->addLayout(rowLayout);
	columnLayout->addWidget(_pRightColumn);

	setLayout(columnLayout);

	connect(_pScaleX, SIGNAL(valueChanged(int)), this, SLOT(scaleXchanged(int)));
}

DisplayWidget* MainWindow::getLeftColumn()
{
	return _pLeftColumn;
}

DisplayWidget* MainWindow::getRightColumn()
{
	return _pRightColumn;
}

void MainWindow::closeEvent(QCloseEvent *event)
{
}

void MainWindow::resizeEvent(QResizeEvent*)
{
	_pController->calculatePositions();
}

void MainWindow::scaleXchanged(int i)
{
	_pController->setTimeScale(i);
}
